package org.bud.boot.controller.test.reply;

import org.bud.boot.controller.test.service.BudService;
import org.bud.boot.io.bit.Streams;
import org.bud.boot.result.R;
import org.bud.excel.expot.bit.ExportAskBody;
import org.bud.excel.expot.bit.QueryArg;
import org.bud.excel.expot.bit.SheetArg;
import org.bud.util.bit.Lists;
import org.bud.util.bit.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author shaun
 * @date 2024/7/19
 * @instruction
 */
@Controller
@RequestMapping("/bit")
public class BitController {

    private BudService budService;

    @Autowired
    public void setBudService(BudService budService){
        this.budService = budService;
    }

    @RequestMapping("/bud")
    @ResponseBody
    public R<String[]> ok(@RequestParam(value = "bit",required = false) String[] bit){
        return R.ok(bit);
    }

    @RequestMapping("/bud-excel")
    public void stream(String file, HttpServletResponse response){
        Streams.stream(response,file, budService.aks());
    }

    @RequestMapping("/bud-excel-stream")
    public ResponseEntity<StreamingResponseBody> stream(String file){
        return Streams.stream(file,  budService.aks());
    }
}
